//
//  MJ_TagTableViewCell.m
//  UEAssistant
//
//  Created by mac on 2018/3/8.
//  Copyright © 2018年 youyixinxi. All rights reserved.
//

#import "MJ_TagTableViewCell.h"

@interface MJ_TagTableViewCell ()

@property (weak, nonatomic) IBOutlet UIButton *tag_One;

@property (weak, nonatomic) IBOutlet UIButton *tag_Two;

@property (weak, nonatomic) IBOutlet UIButton *tag_Three;
@end

@implementation MJ_TagTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.separatorInset =UIEdgeInsetsMake(0, 15, 0, 15);
}

- (void)setSelectedTagsList:(NSArray *)selectedTagsList {
    _selectedTagsList  = selectedTagsList;
    NSArray *buttonArray = @[_tag_One,_tag_Two,_tag_Three];
    NSInteger index = 0;
    for (UIButton *btn in buttonArray) {
        if (index >= selectedTagsList.count) {
            btn.hidden = YES;
        }else{
            NSString *title = selectedTagsList[index];
            btn.hidden = NO;
            [btn setTitle:title forState:UIControlStateNormal];
        }
        index ++;
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (IBAction)clickTagPressed:(UIButton *)sender {
    NSMutableArray *arr = [NSMutableArray arrayWithArray:self.selectedTagsList];
    if ([sender isEqual:_tag_One]) {
        [arr removeObjectAtIndex:0];
    }else if ([sender isEqual:_tag_Two]) {
        [arr removeObjectAtIndex:1];
    }else{
        [arr removeLastObject];
    }
    self.selectedTagsList = arr;
}

@end
